package cz.cvut.fel.gfupan.gui.action;

import cz.cvut.fel.gfupan.gui.Session;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JDialog;
import javax.swing.JFileChooser;

public class OpenAction implements ActionListener {

    private JDialog root;
    private JFileChooser fc;

    public OpenAction(JDialog root) {
        this.root = root;
        fc = new JFileChooser();
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        if (root != null) {
            root.dispose();
        }
        int returnVal = fc.showOpenDialog(root);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //loads file
        } else {
        }

        Session.getInstance().demoMeasure();
    }
}
